package com.study.design.singleton;

/**
 * 枚举实现
 *
 * @Author 网易云课堂微专业-java高级开发工程师【allen老师】
 * @Version 1.0
 */
public class Singleton6 {

    // 私有构造函数
    private Singleton6() {
    }

    public static Singleton6 getInstance() {
        return SingletonEnum.INSTANCE.getInstance();
    }

    private enum SingletonEnum {

        INSTANCE;

        private Singleton6 singleton;

        // JVM 保证这个方法只调用一次
        SingletonEnum() {
            singleton = new Singleton6();
        }

        public Singleton6 getInstance() {
            return singleton;
        }
    }
}
